package top.hkyzf.study.leetcode.array;

import org.junit.Test;

/**
 * description: 
 * @author zhufeng
 * @date 2023/5/5 0005 11:26
 * @version V1.0
 */
public class 处理用时最长的那个任务的员工_2432 {
    @Test
    public void testHardestWorker () {
        int n = 10;
        int[][] logs = {{0,10},{1,20}};
        System.out.println(hardestWorker(n, logs));
    }

    public int hardestWorker(int n, int[][] logs) {
        int length = logs.length;
        int minNo = logs[0][0];
        int maxLog = logs[0][1];
        for (int i = 1; i < length; i++) {
            int log = logs[i][1] - logs[i-1][1];
            if (log > maxLog) {
                maxLog = log;
                minNo = logs[i][0];
            } else if (log == maxLog) {
                minNo = Math.min(minNo, logs[i][0]);
            }
        }
        return minNo;
    }
}
